//
// Created by wangjunjun on 2024/9/19.
//
#include <memory>
#include <mutex>

#ifndef WLROBOTICS_UDPCLIENT_H
#define WLROBOTICS_UDPCLIENT_H


class udpClient {
public:
    ~udpClient();
    bool init();
    static udpClient& GetInStance();
    bool SenData(const std::string &data);
private:
    udpClient();
    udpClient(const udpClient&)=delete;
    udpClient& operator =(const udpClient&)= delete;
    void createSocket();
    void connectToServer();
private:
    static  std::unique_ptr<udpClient> m_InStance;
    static  std::once_flag m_Flag;
    int m_socket;
    bool m_isConnected;
    std::string m_serverAddress;
    uint16_t  m_port;

};


#endif //WLROBOTICS_UDPCLIENT_H
